<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$app->get('/', function () use ($app) {
    return $app->version();
});
//$app->group(['prefix'=>'admin'],function() use($app){
//
//});
$app->get('foo',['uses'=>'Controller@test']);
//$app->get('product',['uses'=>'ProductController@index']);
$app->group(['prefix'=>'product'],function()use($app){
    $app->get('',['uses'=>'ProductController@index']);
    $app->get('list',['uses'=>'ProductController@lister']);
    $app->get('detail/{id}',['uses'=>'ProductController@detail']);
    $app->post('search',['uses'=>'ProductController@search']);
});
$app->group(['prefix' => 'redis'],function()use($app){
    $app->get('cache','RedisController@cache');
    $app->get('redis','RedisController@redis');
//    $app->get('/', function () use ($app) {
//        //return $app->version();
//        Cache::put('lumen', 'Hello, Lumen.', 5);
//        return Cache::get('lumen');
//    });
});
$app->group(['prefix'=>'form'],function()use($app){
    $app->post('add',['uses'=>'BiaoController@add']);
    $app->post('safe',['uses'=>'BiaoController@safe']);
    $app->get('active',['uses'=>'BiaoController@active']);
    $app->get('string',['uses'=>'BiaoController@string']);
    $app->get('json_p',['uses'=>'BiaoController@json_p']);
    $app->get('json_p_response',['uses'=>'BiaoController@json_p_response']);
});

$app->group(['prefix'=>'file'],function()use($app){
    $app->post('upload','FileController@uploads');
    $app->post('valid','FileController@valid_uploads');
    $app->post('files','FileController@files_uploads');
});

$app->group(['prefix'=>'route'],function()use($app){
    $app->get('arrow','RouteController@arrow');
    $app->get('point',['uses'=>'RouteController@point','as'=>'route_arrow']);
    $app->get('down',['uses'=>'RouteController@down']);
    $app->get('write_file',['uses'=>'RouteController@write_file']);
});

$app->group(['prefix'=>'user'],function()use($app){
    $app->get('',['middleware'=>'user',function(){
    }]);
    $app->get('login',['uses'=>'UserController@login','as'=>'login']);
    $app->get('encrypt',['uses'=>'UserController@encrypt','as'=>'encrypt']);
    $app->get('crypt',['uses'=>'UserController@crypt','as'=>'crypt']);
});

$app->group(['prefix'=>'job'],function()use($app){
    $app->get('','JobController@addQueue');
});

$app->group(['prefix'=>'table'],function()use($app){
   $app->get('create','TableController@create_table');
   $app->get('insert','TableController@insert_data');
});
